/**
 * test case entry.
 */
var globalConfigs = require("./globalConfigs.js");

var http = require('http');
var tk = "9glVWbBiIEf3_xCyDmsQeZoJtOaLWbeGtIS5jQ==";
function httpClient() {
	var options = {
		hostname : 'localhost',
		port : 4001,
		//path : '/login',
		path :'/startTask',
		//path : '/loadTasks',
		// path : '/loadURMsg',
		//path : '/setReadMsg',
		method : 'get',
		//method : 'post',
		headers : {
			taskId : "9f712aa5518c0305e24d54f8875a7828",
			account : "helloworld",
			password : "123456",
			tk : tk
		}
	};

	var req = http.request(options, function(res) {
		console.log('STATUS: ' + res.statusCode);
		console.log('HEADERS: ' + JSON.stringify(res.headers));
		res.setEncoding('utf8');
		res.on('data', function(chunk) {
			console.log('BODY: ' + chunk);
		});
	});

	req.on('error', function(e) {
		console.log('problem with request: ' + e.message);
	});

	// write data to request body
//	var body = {
//		ids : [ ]
//	};
//	for (var x = 1; x < 100; x += 1) {
//		body.ids.push("" + x);
//	}
//	
//	req.write(JSON.stringify(body));
	req.end();
}

//httpClient();
var WebSocket = require('ws');
function websockClient() {
	var ws = new WebSocket('ws://192.168.1.195:4001/ws', {
		headers : {
			tk : tk
		}
	});

	ws.on('open', function() {
		ws.send('something');
		ws.send('something2');
		ws.send('something3');
	});

	ws.on('message', function(message) {
		console.log('received: %s', message);
	});

	ws.on('error', function() {
		console.log('oh, no');
	});
}

websockClient();
